4 HANDLE g_vbCommonHeap
=NULL
;
5 const zeromemory_t zeromemory
;
7 void* _cdecl
operator new(size_t cbSize
, const zeromemory_t
&)
9 #if DEBUG && _X86_ && IDE // see vsproject\vb\vbprj\vbprj.cpp
10 // if you get a leak report from VSAssert you'll get a line like:
11 // d:\dd\vsleditor\src\vb\language\include\vbheap.cpp(10189270): 0x0DF2E258, bytes = 8, nAlloc=133514, TID=0x1104
12 // Break into the debugger. Take the # in parens, put it in Watch window: turn on hex display->it shows addr of caller
13 // Go to disassembly, put the address in the Address bar hit enter. Bingo: you're at the caller that didn't free!
14 // see http://blogs.msdn.com/calvin_hsia/archive/2009/01/19/9341632.aspx
16 _asm
{ mov EbpRegister
, ebp
};
17 UINT CallerAddr
= *(((size_t *)EbpRegister
)+1) ;
19 // CallerAddr -= (size_t)g_hinstDll;
21 void *mem
= VsDebugAllocInternal(g_vbCommonHeap
, HEAP_ZERO_MEMORY
| HEAP_GENERATE_EXCEPTIONS
, (cbSize
), __FILE__
,CallerAddr
, INSTANCE_GLOBAL
, NULL
);
23 // no need to ZeroMemory: we used HEAP_ZERO_MEMORY flag
28 void *mem
= ::operator new(cbSize
);
29 ZeroMemory(mem
, cbSize
);
36 void* _cdecl
operator new[](size_t cbSize
, const zeromemory_t
&)
38 #if DEBUG && _X86_ && IDE // // see vsproject\vb\vbprj\vbprj.cpp
39 // if you get a leak report from VSAssert you'll get a line like:
40 // d:\dd\vsleditor\src\vb\language\include\vbheap.cpp(10189270): 0x0DF2E258, bytes = 8, nAlloc=133514, TID=0x1104
41 // Break into the debugger. Take the # in parens, put it in Watch window: turn on hex display->it shows addr of caller
42 // Go to disassembly, put the address in the Address bar hit enter. Bingo: you're at the caller that didn't free!
43 // see http://blogs.msdn.com/calvin_hsia/archive/2009/01/19/9341632.aspx
45 _asm
{ mov EbpRegister
, ebp
};
46 UINT CallerAddr
= *(((size_t *)EbpRegister
)+1) ;
48 // CallerAddr -= (size_t)g_hinstDll;
50 void *mem
= VsDebugAllocInternal(g_vbCommonHeap
, HEAP_ZERO_MEMORY
| HEAP_GENERATE_EXCEPTIONS
, (cbSize
), __FILE__
,CallerAddr
, INSTANCE_GLOBAL
, NULL
);
51 // no need to ZeroMemory: we used HEAP_ZERO_MEMORY flag
56 void *mem
= ::operator new(cbSize
);
57 ZeroMemory(mem
, cbSize
);
62 void* _cdecl
operator new(size_t cbSize
, NorlsAllocator
&norls
)
64 return norls
.Alloc(cbSize
);